#include <QMessageBox>
#include "javascriptconsoleplugin.h"

Qt::DockWidgetArea JavascriptConsolePlugin::dockWidgetArea()
{
    return Qt::BottomDockWidgetArea;
}

QMenu* JavascriptConsolePlugin::menu(QMenu *inMenu)
{
    createActions();

    menuBar = inMenu->addMenu(tr("Console Javascript"));
    menuBar->addAction(toggleViewAction());
    menuBar->addAction(helpJavascriptAction);
    menuBar->addAction(aboutJavascriptAction);

    return menuBar;
}

void JavascriptConsolePlugin::createActions()
{
    helpJavascriptAction = new QAction(tr("help"), parent());
    helpJavascriptAction->setStatusTip(tr("Ajuda"));
    connect(helpJavascriptAction, SIGNAL(triggered()), this, SLOT(help()));

    aboutJavascriptAction = new QAction(tr("About"), parent());
    aboutJavascriptAction->setStatusTip(tr("About"));
    connect(aboutJavascriptAction, SIGNAL(triggered()), this, SLOT(about()));
}

void JavascriptConsolePlugin::setupDock()
{
    mainWidget = new QWidget(this);

    this->setWindowTitle(tr("Javascript Console"));
    setAllowedAreas(Qt::AllDockWidgetAreas);
    setWidget(mainWidget);
}

QDockWidget* JavascriptConsolePlugin::dock()
{
    setupDock();
    return qobject_cast<QDockWidget *>(this);
}

void JavascriptConsolePlugin::help()
{

}

void JavascriptConsolePlugin::about()
{
    QMessageBox::about(this, tr("Sobre o plugin Javascript Console"), tr("Developed by Tiago Natel de Moura"));
}

Q_EXPORT_PLUGIN2(javascriptconsole, JavascriptConsolePlugin)
